/* 到货通知物料信息行数据 */
import { requestClient } from '#/api/request';

export namespace IssueLine {
  export interface Params {
    attr1: null;
  }
  export interface Detail {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    detailId: number;
    issueId: number;
    lineId: number;
    materialStockId: null;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: string;
    unitOfMeasure: string;
    unitName: null;
    quantity: number;
    batchId: null;
    batchCode: null;
    warehouseId: null;
    warehouseCode: null;
    warehouseName: null;
    locationId: null;
    locationCode: null;
    locationName: null;
    areaId: null;
    areaCode: null;
    areaName: null;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    lineId: number;
    issueId: number;
    materialStockId: null;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: string;
    unitOfMeasure: string;
    unitName: string;
    quantityIssued: number;
    batchId: null;
    batchCode: null;
    attr2: null;
    attr3: number;
    attr4: number;
    details: Detail[];
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
    issueId: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表及详情
export const getIssueLineAndDetailTableList = (
  params: IssueLine.GetListParams,
) =>
  requestClient.get<IssueLine.GetListReturn>(
    '/mes/wm/issueline/listWithDetail',
    {
      params,
    },
  );
export const getIssueLineTableList = (params: IssueLine.GetListParams) =>
  requestClient.get<IssueLine.GetListReturn>('/mes/wm/issueline/list', {
    params,
  });

// 增加入库单行信息
export const addIssueLine = (data: IssueLine.Row) =>
  requestClient.post<IssueLine.GetListReturn>('/mes/wm/issueline', data);

// 删除入库单行信息
export const deleteIssueLine = (id: string) =>
  requestClient.delete<IssueLine.GetListReturn>(`/mes/wm/issueline/${id}`);

// 修改入库单设置
export const updateIssueLine = (data: IssueLine.Row) =>
  requestClient.put<IssueLine.GetListReturn>('/mes/wm/issueline', data);
